//
//  PaperWrongViewManager.m
//  ZYOnlineSchool
//
//  Created by 毕武侠 on 2017/2/28.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "PaperWrongViewManager.h"
#import "CommentInputView.h"
#import "PaperModuleModel.h"

@interface PaperWrongViewManager () <CommentDelegate>

@property (nonatomic, strong) CommentInputView *view;
@property (nonatomic, strong) PaperAnswerModel *model;

@end

@implementation PaperWrongViewManager
@dynamic view;
@dynamic model;

- (void)setupConfigure {
    [super setupConfigure];
    
    self.view = [[CommentInputView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.view.delegate = self;
    if (self.superView) {
        [self.superView addSubview:self.view];
    }
    self.view.hidden = YES;
    
    @weakify(self)
    self.url = @"Question/question_wrong";
    self.rmodel = @"BaseModel";
    
    [self setupLoadingView:self.superView];
    [self.receiveSignal subscribeNext:^(NSMutableArray *receive) {
        @strongify(self)
        [self.view clearText];
        [self.view hidden];
        [MBProgressHUD showTextOnly:self.superView message:self.msg];
    }];
}

- (void)setWrongSignal:(RACSignal *)wrongSignal {
    _wrongSignal = wrongSignal;
    
    @weakify(self)
    [wrongSignal subscribeNext:^(id x) {
        @strongify(self)
        if ([x isKindOfClass:[PaperAnswerModel class]]) {
            self.model = x;
            [self.view show];
        }
    }];
}

- (void)commentInputViewDidSend:(NSString *)text {
    [self loadDataWithParams:@{@"question_id" : self.model.ques_id ? : @"",
                               @"wrong_content" : text,
                               @"mobile" : [ZYUserManager userInfo].phone ? : @"",
                               @"wrong_type_value":@"0",
                               @"ques_type":self.model.ques_type ? : @""}];
    NSLog(@"input %ld %@-----%@", self.model.ques_num, text,self.model.ques_id);
}

@end
